package com.lyb.spzx.pay.configuration;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.lyb.spzx.pay.properties.AlipayProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AlipayConfiguration {
    @Autowired
    AlipayProperties alipayProperties;

    @Bean
    public AlipayClient alipayClient(){
        AlipayClient alipayClient = new DefaultAlipayClient(alipayProperties.getAlipayUrl(),
                alipayProperties.getAppId()
                , alipayProperties.getAppPrivateKey()
                , alipayProperties.alipayPublicKey
                ,AlipayProperties.format
                ,AlipayProperties.charset
                ,AlipayProperties.sign_type);

        return alipayClient;
    }
}
